package com.testapp.bluetoothtest08.cipher.tool.user;


import com.testapp.bluetoothtest08.cipher.tool.NumberTools;
import com.testapp.bluetoothtest08.cipher.tool.Parameter;
import com.testapp.bluetoothtest08.cipher.tool.UniversalTools;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;


public class UserUniversalTools {
    
    UniversalTools universalTools = new UniversalTools();
    NumberTools numberTools = new NumberTools();
    Parameter paramer = new Parameter();
    
    public ArrayList<BigInteger> listR(){
        ArrayList<BigInteger> rList = new ArrayList<>();
        rList.add(numberTools.generateNum(paramer.EpisilonLamK));                                                                                 //r1   random (y-2^gama)
        rList.add(numberTools.generateNum(paramer.EpisilonLamK));                                                                                 //r2   random x
        rList.add(numberTools.generateNum(paramer.EpisilonLsigmaK));                                                                                 //r3   random s
        rList.add(numberTools.generateNum(paramer.EpisilonLamK));                                                                                 //r4   random t
        rList.add(numberTools.generateNum(paramer.EpisilonLK));                                                                                 //r5   random i
        rList.add(numberTools.generateNum(paramer.EpisilonLK));                                                                                 //r6   random e
        rList.add(numberTools.generateNum(paramer.EpisilonLK));                                                                                 //r7   random d
        rList.add(numberTools.generateNum(paramer.EpisilonGamaLamK));                                                                                 //r8   random w'
        rList.add(numberTools.generateNum(paramer.EpisilonLamK));                                                                                 //r9   random r
        rList.add(numberTools.generateNum(paramer.EpisilonLamK));                                                                                 //r10   random r'
        rList.add(numberTools.generateNum(paramer.EpisilonDoulK));                                                                                 //r11   random ie
        rList.add(numberTools.generateNum(paramer.EpisilonLamLK));                                                                                 //r12   random r'e
        rList.add(numberTools.generateNum(paramer.EpisilonLK));                                                                                 //r13   random ec
        rList.add(numberTools.generateNum(paramer.EpisilonLK));                                                                                 //r14   random m
        rList.add(numberTools.generateNum(paramer.EpisilonDouLsigK));                                                                                 //r15   random (ic+t)^(-1)(ic+s)
        rList.add(numberTools.generateNum(paramer.EpisilonDouLsigK));                                                                                 //r16   random (ic+s)^(-1)(ic+t)
        return rList;
    }

    public ArrayList<BigInteger> getSecParams(BigInteger Cku){
        ArrayList<BigInteger> secParams = new ArrayList<>();
        secParams.add(Cku);                                // secparams0    secretky
        BigInteger t1 = numberTools.generateNum(Parameter.Lamtha);                //  secparams1    t1
        if (t1.mod(Parameter.bigTwo).equals(Parameter.bigZero)){           // confirm that t1 is odd
            t1 = t1.add(Parameter.bigOne);
        }
        secParams.add(t1);
        secParams.add(numberTools.generateNum(Parameter.Lamtha));                 //  secparams2     x
        BigInteger s = numberTools.generateNum(Parameter.Lsigma);
        if (s.mod(Parameter.bigTwo).equals(Parameter.bigOne)){             // confirm that s is even
            s = s.add(Parameter.bigOne);
        }
        secParams.add(s);                                                 //   secparams3     s
        secParams.add(t1);                                                //   secparams4     t
        secParams.add(numberTools.generateNum(Parameter.L));                //    secparams5     i
        secParams.add(numberTools.generateNum(Parameter.L));                //    secparams6     e
        secParams.add(numberTools.generateNum(Parameter.L));                //    secparams7     d
        secParams.add(numberTools.generateNum(Parameter.Lamtha));                //    secparams8     w
        return secParams;
    }

}
